<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page import="java.util.*"%>
<%@ page import="goods.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ include file="/Dmyna/head.jsp" %>

<script language="javascript" src="${WEB_ROOT}/js/jquery-1.7.2.js"></script>
<script language="javascript" src="${WEB_ROOT}/js/common.js"></script>

<style type="text/css">
.dmyna_main_banner { height:413px !important; position:relative; margin:0 19px 0 20px; }
.dmyna_main_banner .imgs { border:1px solid #e6e6e6; }
.dmyna_main_banner .btns { overflow:hidden; margin-left:14px; position:absolute; left:0; bottom:9px; }
.dmyna_main_banner .btns li { float:left; }
.dmyna_main_banner .btns li a { display:block; width:154px; text-align:center; color:#474747; padding:8px 0; border:1px solid #e1e1e1; background:#fff; letter-spacing:-1px;}
.dmyna_main_banner .btns li a.on { color:#fff; border:1px solid #252525; background:#252525; }
.dmyna_main_banner .btns li a:hover { color:#fff; border:1px solid #252525; background:#252525; }
</style>

<table width="900" align=center cellpadding=0 cellspacing=0 >
<tr>
	<td width="100%">
		<table width="100%" align=center cellpadding=0 cellspacing=0 border="0" >
		<tr>
			<td width="100%">
<div class="dmyna_main_banner js_rollBanner">
	<p class="imgs">
	<a class="item" href="javascript:goView('M2G0050')">
	<img src="${WEB_ROOT}/img/goods/main_3.png" width="900" alt="images" />
	</a>
	<a class="item" href="javascript:goView('M1G0004')" style="display:none;">
	<img src="${WEB_ROOT}/img/goods/main_2.png" width="900" alt="images" />
	</a>
	<a class="item" href="javascript:goView('M1G0067')" style="display:none;">
	<img src="${WEB_ROOT}/img/goods/main_1.png" width="900" alt="images" />
	</a>
	</p>
	<!-- <ul class="btns">
		<li><a href="#banner">링크1</a></li>
		<li><a href="#banner">링크2</a></li>
		<li><a href="#banner">링크3</a></li>
	</ul> -->
</div>
			</td>
		</tr>
		</table>
	</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr >
	<td width="100%">
		<table width="900" align=center cellpadding=0 cellspacing=0 border="0" >
		<tr>
			<td width= "100%">
				<a class="img" href="javascript:goView('M1G0065')"><img src="${WEB_ROOT}/img/goods/02.png"  width="450"  border='1' ></a>
			</td>
			<td width= "100%">
				<a class="img" href="javascript:goView('M2G0066')"><img src="${WEB_ROOT}/img/goods/03.png"  width="450"  border='1' ></a>
			</td>
		</tr>
		</table>
	</td>
</tr>
<tr><td>&nbsp;</td></tr>
<%
GoodsManager mainGoods = GoodsManager.getInstance();
int countMain = mainGoods.countMain();
int startrow = 0, endRow = 20;

List<GoodsItem> mainList = mainGoods.selectMainList(startrow, endRow);

int blankCnt = 4 - (countMain % 4);
if(blankCnt == 4) blankCnt=0;
%>

<c:set var="mainList" value="<%=mainList%>" />
<c:set var="countMain" value="<%=countMain%>" />
<c:set var="blankCnt" value="<%=blankCnt%>" />

<tr>
	<td width="100%">

		<table width="900" align=center cellpadding=0 cellspacing=0 border="0" >
		<c:if test="${empty mainList }">
		<tr>
			<td bgcolor="#f0f0f0" colspan="5" height="100" align="center">등록된상품이 없습니다.</td>
		</tr>
		</c:if>

		<c:if test="${!empty mainList }">
			<c:set var="goodsCnt" value="<%=startrow%>" />
			<c:forEach var="rowcnt" begin="0" end="4">
				<tr>
					<c:forEach var="goodsMain" items="${mainList}" begin="${ (rowcnt*4) }" end="${(rowcnt*4) + 3 }">
						<td width="25%">
							<TABLE width="100%" height="190" border="0" cellpadding="0"cellspacing="0">

								<!-- 리스트 시작 -->
								<tr>
									<td height="224" align="center"><a class="img" href="javascript:goView('${goodsMain.gs_code }')"> 
									<img src="${WEB_ROOT}/goods/upload/${goodsMain.gs_img }" width="170" border='1'>
									</a></td>
								</tr>
								<tr height="20"><td class="subject" align="center">
								<c:if test="${goodsMain.gs_view_cnt >= 50 }">
								<img src="${WEB_ROOT}/img/goods/goods_hititem.gif" />
								</c:if>
								<c:if test="${goodsMain.gs_view_cnt < 50 && goodsMain.gs_view_cnt > 20 }">
								<img src="${WEB_ROOT}/img/goods/goods_coolitem.gif" />
								</c:if>
								<c:if test="${goodsMain.gs_org_price > goodsMain.gs_sale_price && goodsMain.gs_org_price - goodsMain.gs_sale_price >= 10000 }">
								<img src="${WEB_ROOT}/img/goods/goods_special.gif" />
								</c:if>
								<img src="${WEB_ROOT}/img/goods/goods_order.gif" /></td>
								</tr>
								<tr height="30">
									<%-- <td class="subject" align="center">상품명 : ${goodsMain.gs_name }</td> --%>
									<td class="subject" align="center"><a class="img" href="javascript:goView('${goodsMain.gs_code }')"><font style="color: #778899; font-weight:bold">${goodsMain.gs_name }</font></a></td>
								</tr>
								<tr height="30">
									<%-- <td class="price" align="center">가격 : ${goodsMain.gs_org_price }원</td> --%>
									<c:choose>
									<c:when test="${goodsMain.gs_org_price == goodsMain.gs_sale_price }">
									<td class="price" align="center"><font style="font-weight:bold"  ><fmt:formatNumber value="${goodsMain.gs_org_price }" type="number"/>원</font> </td>
									</c:when>
									<c:otherwise>
									<td class="price" align="center"><strike><fmt:formatNumber value="${goodsMain.gs_org_price }" type="number"/>원</strike> &nbsp;<font style="font-weight:bold"  > <fmt:formatNumber value="${goodsMain.gs_sale_price }" type="number"/>원</font></td>
									</c:otherwise>
									</c:choose>
								</tr>
								<tr>
									<td colspan=2 height=1 bgcolor=#e7e7e7></td>
								</tr>
								<tr>
									<td><br /> <br /></td>
								</tr>
								<!-- 리스트 종료 -->

							</TABLE>
						</td>
						<c:set var="goodsCnt" value="${ (goodsCnt+1) }" />
						<c:if test="${countMain == goodsCnt }">
						
						<c:forEach var="blankcol"  begin="1" end="${blankCnt }">
						<TD width="25%">
							<TABLE width="100%" height="190" border="0" cellpadding="0"cellspacing="0">
								<TR >
									<TD height="100%"><a class="" href=""> <img src="${WEB_ROOT}/img/goods/blank.png" width="224" border='0'>
									</a></TD>
								</TR>
								<tr height="20">
									<td class="subject" align="center">&nbsp;</td>
								</tr>
								<tr height="30">
									<td class="subject" align="center">&nbsp;</td>
								</tr>
								<tr height="30">
									<td class="price" align="center">&nbsp;</td>
								</tr>
								<tr>
									<td colspan=2 height=1 bgcolor=#e7e7e7></td>
								</tr>
								<tr>
									<td><br /> <br /></td>
								</tr>
							</TABLE>
						</TD>
						</c:forEach>
						
					</c:if>
					</c:forEach>
				</tr>
			</c:forEach>
		</c:if>

		</table>

	</td>
</tr>
<tr><td>&nbsp;</td></tr>
</table>

<script language="JavaScript">
	function goView(gscode) {
		document.move.action = "${WEB_ROOT }/goods/goodsView.jsp";
		document.move.GS_CODE.value = gscode;
		document.move.submit();
	}
</script>

<form name="move" method="post">
	<input type="hidden" name="GS_CODE" value="" /> 
</form>

<%@ include file="/Dmyna/tail.jsp" %>

